'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { merchant_disheService } from '../service/merchant_dishe';

/** 菜品API对象 */
@prefix('merchantdishe')
class Merchant_disheController {
    /**
     * @api {post} /merchantdishe/queryall  查询所有菜品-小程序
     * @apiDescription 查询菜品
     * @apiName queryall
     * @apiParam (参数) {String} mid    商户_id
     * @apiSampleRequest /merchantdishe/queryall
     * @apiGroup merchantdishe
     * @apiVersion 1.0.0
     */
    @router('/queryall', { method: 'post' })
    async queryall(ctx: Koa.Context) {
        let result = await merchant_disheService.queryall(ctx.request.body);
        response(ctx, result);
    }
    /**
     * @api {post} /merchantdishe/querypage  查询商户菜品列表（小程序）
     * @apiDescription 查询商户菜品列表（小程序）
     * @apiName querypage
     * @apiParam (参数) {String} offset   页码
     * @apiParam (参数) {String} limit    每页显示条数
     * @apiParam (参数) {String} mid    商户id
     * @apiSampleRequest /merchantdishe/querypage
     * @apiGroup merchantdishe
     * @apiVersion 1.0.0
     */
    @router('/querypage', { method: 'post' })
    async querypage(ctx: Koa.Context) {
        let result = await merchant_disheService.querypage(ctx.request.body);
        response(ctx, result);
    }
    /**
     * @api {post} /merchantdishe/query  查询商户菜品列表（PC）
     * @apiDescription 查询商户菜品列表（PC）
     * @apiName query
     * @apiParam (参数) {String} offset   页码
     * @apiParam (参数) {String} limit    每页显示条数
     * @apiParam (参数) {String} mid    商户_id
     * @apiParam (参数) {String} name    菜品名称
     * @apiSampleRequest /merchantdishe/query
     * @apiGroup merchantdishe
     * @apiVersion 1.0.0
     */
    @router('/query', { method: 'post' })
    async query(ctx: Koa.Context) {
        let result = await merchant_disheService.query(ctx.request.body);
        response(ctx, result);
    }
    /**
     * @api {post} /merchantdishe/save  保存菜品
     * @apiDescription 保存菜品
     * @apiName save
     * @apiParam (参数) {String} doc  菜品对象
     * @apiSampleRequest /merchantdishe/save
     * @apiGroup merchantdishe
     * @apiVersion 1.0.0
     */
    @router('/save', { method: 'post' })
    async save(ctx: Koa.Context) {
        let result = await merchant_disheService.save(ctx.request.body);
        response(ctx, result);
    }
    /**
     * @api {get} /merchantdishe/queryById/:id  获取菜品信息
     * @apiDescription 获取菜品信息
     * @apiName queryById/:id
     * @apiParam (参数) {String} id  菜品id
     * @apiSampleRequest /merchantdishe/queryById/:id
     * @apiGroup merchantdishe
     * @apiVersion 1.0.0
     */
    @router('/queryById/:id')
    async queryById(ctx: Koa.Context) {
        let result = await merchant_disheService.queryById(ctx.params.id);
        response(ctx, result);
    }
    /**
    * 下架菜品
    * @api {get} /merchantdishe/lock 下架菜品(PC)
    * @apiDescription 下架菜品
    * @apiName lock
    * @apiParam (参数) {String} id  菜品id
    * @apiSampleRequest /merchantdishe/lock
    * @apiGroup merchantdishe
    * @apiVersion 1.0.0
    */
   @router('/lock/:id')
   async lock(ctx: Koa.Context) {
       let result = await merchant_disheService.lock(ctx.params.id);
       response(ctx, result);
   }
   /**
   * 上架菜品
   * @api {get} /merchantdishe/open 上架菜品(PC)
   * @apiDescription 上架菜品
   * @apiName open
   * @apiParam (参数) {String} id  用户id
   * @apiSampleRequest /merchantdishe/open
   * @apiGroup merchantdishe
   * @apiVersion 1.0.0
   */
   @router('/open/:id')
   async open(ctx: Koa.Context) {
       let result = await merchant_disheService.open(ctx.params.id);
       response(ctx, result);
   }
   
}